<!DOCTYPE html>
<html lang="en">
<head>
  <meta charset="UTF-8">
  <meta http-equiv="X-UA-Compatible" content="IE=edge">
  <meta name="viewport" content="width=device-width, initial-scale=1.0">
  <title>事件对象event</title>
</head>
<body>
  <div id="app">
    <p>count值为{{count}}</p>
    <button @click="addCount">+1</button>
  </div>
  <script src="../code/lib/vue-2.6.12.js"></script>
  <script>
  const vm=  new Vue({
    el:'#app',
    data:{
      count:0
    },
    methods: {
      addCount(e){
        const newBgColor=e.target.style.background
        e.target.style.background=newBgColor==='red'?'':'red'
        this.count+=1
      }
    },

  })
  </script>
</body>
</html>